﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BookStore.Bussiness;
using BookStore.Data;

namespace BookStore.Controls
{
    public partial class Catagory : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string s = Request.QueryString["catogoryID"];
                if (string.IsNullOrEmpty(s) == false)
                {
                    Repeater1.DataSource = productService.Get_ProductAsTable("tblProduct.catogoryID=" + s, "");
                    Repeater1.DataBind();
                }
                else
                {
                    Repeater1.DataSource = productService.Get_ProductAsTable("tblProduct.catogoryID=2", "");
                    Repeater1.DataBind();
                }
            }
        }
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            LinkButton lnb = (LinkButton)sender;
            int id = Convert.ToInt32(lnb.CommandArgument);
            productService biz = new productService();
            productInfo sp = biz.getById(id);

            Cart objCart = new Cart();
            if (Session["cart"] != null)
                objCart = (Cart)Session["cart"];
            objCart.AddToCart(sp);
            Session["cart"] = objCart;
        }
        protected void lbnimg_Click(object sender, EventArgs e)
        {
            LinkButton lnb = (LinkButton)sender;
            string id = lnb.CommandArgument;
            Response.Redirect("Productdetail.aspx?productId=" + id);
        }
    }
}